#include <ros/ros.h>
#include <sensor_msgs/LaserScan.h>

void lidar_callback(const sensor_msgs::LaserScan msgs)
{
    float fmidist = msgs.ranges[180];
    ROS_INFO("前方测距 range[180]   =  %f  米", fmidist);
}
int main(int argc, char* argv[])
{
    setlocale(LC_CTYPE, "zh_CN.utf8");
  ros::init(argc, argv, "lidar_node");
  ros::NodeHandle  nh;
  ros::Subscriber sub = nh.subscribe("/scan", 10, &lidar_callback);
 ros::spin();



    return 0;
}